package dptest;

import java.util.Arrays;

public class t45 {
	public static void main(String[] args) {
		int nums [] = {2,3,0,1,4};
		int dp [] = new int [nums.length];
		dp[0] = 0;
		for(int i = 1 ; i< nums.length; i++) {
			dp[i] = Integer.MAX_VALUE;
			for(int j = 0; j<i; j++) {
				if(i-j<=nums[j]&& dp[j]!=Integer.MAX_VALUE) {
					dp[i] = Math.min(dp[i],dp[j]+1);
					break;
				}
			}
		}
		System.out.println(Arrays.toString(dp));
		System.out.println(dp[nums.length-1]);
		//return dp[nums.length-1];
	}
}
